<template>
  <div>
    <criteria-paged :model="model" v-ref:paged>
      <criteria partial='criteria' @condition-changed='search'>
        <div novalidate class="form-inline auto" partial>
          <div class="form-group">
          <!-- 用户名: -->
            <input type="text" class="form-control" v-model="model.f_user_oldname" v-on:keyup.enter="search"
            placeholder='用户名' condition="f_user_oldname like '{}%'">
          </div>
          <div class="form-group">
          <!-- 用户编号: -->
            <input type="text" class="form-control" v-model="model.f_user_oldid" v-on:keyup.enter="search"
            placeholder='用户编号' condition="f_user_oldid like '{}%'">
          </div>
          <!-- <div class="form-group">
            <label for="f_subcompany">分公司：</label>
            <v-select id="f_subcompany"
            placeholder='请选择'
            :value.sync="$parent.$parent.model.f_old_subcompany"
            :options='$parent.$parent.f_divisions'
            close-on-select clear-button></v-select>
          </div> -->
          <div class="form-group">
            <!-- <label for="f_subcompany">分公司：</label> -->
            <v-select id="f_subcompany"
            placeholder='分公司'
            :value.sync="$parent.$parent.model.f_subcompany"
            :options='$parent.$parent.subcompanyType'
            close-on-select clear-button></v-select>
          </div>
          <div class="form-group">
            <!-- 审核状态： -->
            <v-select id="f_approved"
            placeholder='请选择审核状态'
            v-model='model.f_approved'
            :value.sync="$parent.$parent.model.f_approved"
            :options='$parent.$parent.f_approval_states'
            condition="f_subcompany='{}'"
            close-on-select clear-button></v-select>
          </div>
          <div class="form-group">
            <button class="btn btn-success width-80" @click="search()">查询</button>
          </div>
        </div>
      </criteria>
      <data-grid :model="model" partial='list' v-ref:grid>
        <template partial='head'>
          <tr>
            <th>用户ID</th>
            <th>分公司</th>
            <th>用户姓名</th>
            <th>审核状态</th>
            <th>审核</th>
          </tr>
        </template>
        <template partial='body'>
          <td>{{row.f_user_oldid}}</td>
          <td>{{row.f_old_subcompany}}</td>
          <td>{{row.f_user_oldname}}</td>
          <td>{{row.f_approved}}</td>
          <td><button class="btn btn-success width-80" @click="$parent.$parent.$parent.change(row)">审核</button></td>
        </template>
      </data-grid>
    </criteria-paged>
  </div>
</template>

<script>
import { PagedList } from 'vue-client'
import Vue from 'vue'
import AppData from '../../stores/AppData'
export default {
  title: '档案审核',
  data () {
    let model = new PagedList('rs/sql/用户档案审核查询', 20, {items: '"*"', tablename: '"t_tmp_userfiles"', groupitem: '""', orderitem: '"f_user_oldid"',
     f_old_subcompany: 'this.f_old_subcompany[0]', f_approved: 'this.f_approved[0]'})
    model.f_old_subcompany = [Vue.f_subcompany]
    model.f_archive_date = ''
    model.f_approved = ['']
    return {
      model: model
      // f_divisions: Vue.f_subcompany != '' ? [{label: Vue.f_subcompany, value: Vue.f_subcompany}]: this.$getParams('安检系统用子公司', [{label:'请选择分公司',value:''}]),
      // f_approval_states: this.$getParams('用户档案审核状态', [{label:'请选择审核状态',value:''}])
    }
  },
  methods: {
    change (row) {
      console.log('111111111111111', row)
      this.$goto('userfile-changeaudit', {model: row})
    }
  },
  computed: {
    f_approval_states () {
      return [{label: '全部', value: ''}, ...AppData.getParam('审核状态')]
    },
    subcompanyType () {
      return [{label: '全部', value: ''}, ...AppData.getParam('分公司')]
    }
  }
}
</script>
